#! /usr/bin/python

import curses
import curses.ascii
import led

stdscr=curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)

num1_map={"1": 2, "2": 4, "3": 1}
num2_map={"4": 2, "5": 4, "6": 1}
num3_map={"a": 0, "s": 1, "d": 4, "f": 5, "g": 2, "h": 3, "j": 6, "k": 7}
num4_map={"7": 2, "8": 4, "9": 1}

while 1:                                                                        
  c = stdscr.getch()
  k=chr(c)
  stdscr.addstr(k)
  
  z=max(10,100)
  
  if k=="q":
    break
  if k in num1_map.keys():
    led.on("/dev/tty1",num1_map[k])
    
  if k in num2_map.keys():
    led.off("/dev/tty1",num2_map[k])

  if k in num3_map.keys():
    led.set("/dev/tty1",num3_map[k])

  if k in num4_map.keys():
    led.toggle("/dev/tty1",num4_map[k])

curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()
